package com.onpositive.inferencer;

import com.onpositive.semantic.model.api.property.IProperty;

public abstract class AbstractTheory  {
	
	protected double correctness;
	protected double weight;
	protected IProperty about;

	public AbstractTheory(IProperty about) {
		super();
		this.about = about;
	}
	public boolean check(Iterable<Object> dataSet) {
		for (Object o:dataSet){
			adjustStats(o);
			if (mayBeDiscarded()){
				return false;
			}
		}
		return true;
	}
	
	public abstract String getId() ;
	
	public abstract int getRating(Iterable<Object> dataSet) ;

	protected abstract void adjustStats(Object sample);
	
	protected boolean mayBeDiscarded(){
		return weight>20 && correctness<0.6;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((about == null) ? 0 : about.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		AbstractTheory other = (AbstractTheory) obj;
		if (about == null) {
			if (other.about != null)
				return false;
		} else if (!about.equals(other.about))
			return false;
		return true;
	}
	public abstract Object getValue(Object o) ;

}
